<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ccut" uri="http://ccut.cn/common/"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="">
	<meta name="author" content="">

	<title>保险赔付列表</title>

	<!-- Bootstrap Core CSS -->
	<link href="${pageContext.request.contextPath}/mb/css/bootstrap.min.css" rel="stylesheet">

	<!-- MetisMenu CSS -->
	<link href="${pageContext.request.contextPath}/mb/css/metisMenu.min.css" rel="stylesheet">

	<!-- DataTables CSS -->
	<link href="${pageContext.request.contextPath}/mb/css/dataTables.bootstrap.css" rel="stylesheet">

	<!-- Custom CSS -->
	<link href="${pageContext.request.contextPath}/mb/css/sb-admin-2.css" rel="stylesheet">

	<!-- Custom Fonts -->
	<link href="${pageContext.request.contextPath}/mb/css/font-awesome.min.css" rel="stylesheet"
		  type="text/css">
	<link href="${pageContext.request.contextPath}/mb/css/boot-crm.css" rel="stylesheet"
		  type="text/css">

	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
	<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->

</head>

<body>

<div class="panel panel-default">
	<div class="panel-body">
		<form class="form-inline" action="${pageContext.request.contextPath }/order/compesatelist" method="post">
			<div class="form-group">
				<label for="order_name">保险名称</label>
				<input type="text" class="form-control" id="order_name" value="" name="order_name">
			</div>
			<div class="form-group">
				<label for="order_uname">订单人</label>
				<input type="text" class="form-control" id="order_uname" name="order_uname">
			</div>
			<div class="form-group">
				<label for="order_state">保险状态</label>
				<select	class="form-control" id="order_state" placeholder="保险状态" name="order_state">
					<option value="">--请选择--</option>
						<option value="0">未完成</option>
						<option value="1">已完成</option>
				</select>
			</div>
			<button type="submit" class="btn btn-primary">查询</button> &nbsp; &nbsp;&nbsp;
		</form>
	</div>
</div>
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<!-- /.panel-heading -->
			<table class="table table-bordered table-striped">
				<thead>
				<tr>
					<th>ID</th>
					<th>保险名称</th>
					<th>保险金额</th>
					<th>购买时间</th>
					<th>保险人</th>
					<th>保险状态</th>
					<th width="120:px">操作</th>

				</tr>
				</thead>
				<tbody>
				<c:forEach items="${page.rows}" var="row">
					<tr>
						<td>${row.order_id}</td>
						<td>${row.order_name}</td>
						<td>${row.order_cost}元</td>
						<td>${row.order_time}</td>
						<td>${row.order_uname}</td>
						<td>
							<c:if test="${row.order_state eq '9'}">
								保险已赔付
							</c:if>
							<c:if test="${row.order_state ne '9'}">
								保险生效中
							</c:if>
						</td>
						<td>
						<c:choose>
							<c:when test="${row.order_state eq '9'}"><!-- 如果 -->
								赔付申请已通过
							</c:when>
							<c:when test="${row.order_state eq 'n'}"><!-- 如果 -->
								赔付申请未通过
							</c:when>
							<c:otherwise> <!-- 否则 -->
								<a href="#" class="btn btn-danger btn-xs" onclick="updateCustomer(${row.order_id},'9')">同意</a>
								<a href="#" class="btn btn-danger btn-xs" onclick="updateCustomer(${row.order_id},'n')">不同意</a>
							</c:otherwise>
						</c:choose>
<%--							<c:if test="${row.order_state eq '9'}">--%>
<%--								赔付申请已通过--%>
<%--							</c:if>--%>
<%--							<c:if test="${row.order_state eq 'n'}">--%>
<%--								赔付申请未通过--%>
<%--							</c:if>--%>

						</td>
					</tr>
				</c:forEach>
				</tbody>
			</table>
			<div class="col-md-12 text-right">
				<ccut:page url="${pageContext.request.contextPath}/order/compesatelist" />
			</div>
			<!-- /.panel-body -->
		</div>
		<!-- /.panel -->
	</div>
	<!-- /.col-lg-12 -->
</div>
</div>
<!-- /#page-wrapper -->
</div>
	<!-- jQuery -->
	<script src="${pageContext.request.contextPath}/mb/js/jquery.min.js"></script>

	<!-- Bootstrap Core JavaScript -->
	<script src="${pageContext.request.contextPath}/mb/js/bootstrap.min.js"></script>

	<!-- Metis Menu Plugin JavaScript -->
	<script src="${pageContext.request.contextPath}/mb/js/metisMenu.min.js"></script>

	<!-- DataTables JavaScript -->
	<script src="${pageContext.request.contextPath}/mb/js/jquery.dataTables.min.js"></script>
	<script src="${pageContext.request.contextPath}/mb/js/dataTables.bootstrap.min.js"></script>

	<!-- Custom Theme JavaScript -->
	<script src="${pageContext.request.contextPath}/mb/js/sb-admin-2.js"></script>

	<script type="text/javascript">
		function editCustomer(id) {
			$.ajax({
				type:"post",
				url:"${pageContext.request.contextPath}/order/edit",
				data:{"id":id},
				success:function(data) {
					$("#edit_order_id").val(data.order_id);
					$("#edit_order_name").val(data.order_name);
					$("#edit_order_cost").val(data.order_cost)
					$("#edit_order_time").val(data.order_time)
					if (data.order_state==0){
						$("#edit_order_state").val('未完成')
					}else{
						$("#edit_order_state").val('已完成')
					}
					$("#edit_order_uid").val(data.order_uid)
					$("#edit_product_id").val(data.product_id)

				}
			});
		}

		function updateCustomer(id,order_state) {
			if(confirm('确认要赔付该订单吗?')) {
				$.post("${pageContext.request.contextPath}/order/update",{"order_id":id,"order_state":order_state},function(data){
					if(data == "0"){
						alert("理赔审批成功！");
					}else{
						alert("理赔审批失败！");
					}
					window.location.reload();
				});
			}
		}
	</script>
</body>

</html>
